<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //手机父类
        function Phone(brand,price){
            this.brand = brand;
            this.price = price;
        }
        //手机一个方法
        Phone.prototype.call = function(){
            console.log('我可以打电话');
        }


        //创建智能手机这个子类
        function SmartPhone(brand,price,color,size){
            Phone.call(this,brand,price)  //这个this就是指的SmartPhone
            this.color = color;
            this.size = size;
        }

        //设置子集构造函数的原型
        SmartPhone.prototype = new Phone;
        SmartPhone.prototype.constructor = SmartPhone;

        //声明子类的一个方法
        SmartPhone.prototype.photo = function(){
            console.log('我可以拍照');
        }

        SmartPhone.prototype.play = function(){
            console.log('我可以玩游戏');
        }

        //实例化一个对象
        const chuizi = new SmartPhone('锤子',2000,'黑色','5.5yinchi')
        console.log(chuizi);


    </script>
    
</body>
</html>